package fy.uap.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Date;
import java.text.SimpleDateFormat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import fy.config.FyConfig;
import fy.uap.bean.FundsBean;
import fy.util.DBUtil;
import fy.util.MyUtil;

public class FundsDao2 {

	private static Log log = LogFactory.getLog(FundsDao.class);

	private FundsBean fundsBean;
	private String uappk_corp = null;// 组织
	private String P_dept = null;// 费用部门
	private String P_type = null;// 费用类型
	private String Abs = null;// 摘要
	private String AbsValue = null;
	// private String root = null;// 后缀
	private static final String insertSQL = "insert into FYFUND_OA_BILLCOST_TEMP (PK_ID,BILL_NO,PK_CORP,PK_COSTSUBJ,CURR_CODE,BILL_DATE,BILL_AMOUNT,ADV_AMOUNT,OPP_CORP,OPP_ACC_NAME,OPP_ACC_NO,OPP_ACC_BANK,OPP_ACC_BANK_TYPE,ABS,MEMO,VOUCHER_COUNT,OPERATOR,OPERATOR_DATE,BILL_STATUS) select ?,?,?,(select nvl(pk_costsubj,'') from dual left join (select a.pk_costsubj from v_fyfund_costsubj_for_oa a where a.costname = ? and rownum = 1) on 1 = 1),?,?,?,?,?,?,?,?,?,?,?,?,?,?,? from dual where not exists(select * from FYFUND_OA_BILLCOST_TEMP t where t.bill_no = ?)";
	private static final String insertCostSQL = "insert into OA_Cost_To_UAP (P_ID,P_CORP,P_DEPT,P_TYPE,P_COST,TS,NOTE)values ( ?, ?, ?, ?, ?, ?, ?)";
	// 查下拉值 注意REF_ENUMID正式和测试不同
	private final static String LOOKUP_XIALA_XINGJI = "SELECT c.SHOWVALUE FROM  CTP_ENUM_ITEM  c WHERE c.ENUMVALUE=? AND c.REF_ENUMID=?";

	public void setFundsBean(FundsBean fundsBean) {
		this.fundsBean = fundsBean;
	}

	public boolean save() {
		Connection conn = null;
		PreparedStatement pst = null;
		// String uappk_corp = null;
		boolean success = false;
		try {
			log.info("Operator:" + fundsBean.getOperator());
			// if (fundsBean.getBill_no().indexOf("FM") != -1||
			// fundsBean.getBill_no().indexOf("CC") != -1) {
			if (fundsBean.getBill_no().indexOf("B") != -1) {
				Abs = fundsBean.getName() + "报销" + fundsBean.getAbs();
				// root = "";
			} else if (fundsBean.getBill_no().indexOf("C") != -1) {
				Abs = fundsBean.getName() + "报销差旅费-" + fundsBean.getReasons();
				// root = "差旅费";
			} else {
				Abs = fundsBean.getAbs();
			}

			if (Abs.length() > 50) {
				AbsValue = Abs.substring(0, 49);
			} else {
				AbsValue = Abs;
			}
			 log.info("Abs:" + Abs + "AbsValue:" + AbsValue);
			/*
			 * }else { AbsValue=fundsBean.getAbs(); // }
			 */
			 
			if (fundsBean.getPk_corp().equals("1044") || fundsBean.getPk_corp().equals("1003")
					|| fundsBean.getPk_corp().equals("1016") || fundsBean.getPk_corp().equals("1043")) {
				uappk_corp = "1002";
			} else {
				uappk_corp = fundsBean.getPk_corp();
			}
			log.info("~~~~~~~pk_corp:" + uappk_corp + "~~fundsBean.getPk_corp():" + fundsBean.getPk_corp()
					+ "~~~fundsBean.getPk_costsubj():" + fundsBean.getPk_costsubj());

			/*
			 * if (fundsBean.getOperator().equals("084655") ||
			 * fundsBean.getOperator().equals("000922")) { log.info("测试Operator:" +
			 * fundsBean.getOperator()); for (int temp = 0;
			 * fundsBean.getP_dept_list().size() > temp; temp++) { CostSave(temp,
			 * fundsBean.getBill_no()); log.info("测试！！！！" + temp); } conn =
			 * connect("oracle.jdbc.driver.OracleDriver",
			 * "jdbc:oracle:thin:@10.112.0.32:1521:uap", "uapnc", "uapnc"); } else { conn =
			 * DBUtil.connect(FyConfig.getUAP_DB_CONFIG()); log.info("正式Operator:" +
			 * fundsBean.getOperator()); }
			 */

			// 原
			/*
			 * if (fundsBean.getBill_no().indexOf("FM") != -1||
			 * fundsBean.getBill_no().indexOf("CC") != -1) { for (int temp = 0;
			 * fundsBean.getP_dept_list().size() > temp; temp++) { CostSave(temp,
			 * fundsBean.getBill_no()); log.info("新增部分:" + temp+fundsBean.getBill_no()); }
			 * 
			 * }
			 */

			// 区别其他单子
			if (fundsBean.getBill_no().indexOf("FM") != -1 || fundsBean.getBill_no().indexOf("CC") != -1) {
				/* if(uappk_corp=="1002") { */
				for (int temp = 0; fundsBean.getP_dept_list().size() > temp; temp++) {
					CostSave(temp, fundsBean.getBill_no());
					log.info("新增部分：" + temp + "单据编号："+fundsBean.getBill_no());
				}
			}

			/*
			 * }else {
			 * 
			 * Date now = new Date(); SimpleDateFormat dateFormat = new
			 * SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// 可以方便地修改日期格式 String costDate =
			 * dateFormat.format(now); for (int temp = 0; fundsBean.getP_dept_list().size()
			 * > temp; temp++) { // CostSave(temp, fundsBean.getBill_no());
			 * 
			 * log.info(fundsBean.getBill_no()+uappk_corp+AbsValue);
			 * 
			 * log.info(fundsBean.getP_dept_list().get(temp)+fundsBean.getP_type_list().get(
			 * temp)+ fundsBean.getP_cost_list().get(temp));
			 * 
			 * log.info("新增部分:" + temp+fundsBean.getBill_no());
			 * CostSaveCC(temp,fundsBean.getBill_no()); } }
			 */

			conn = DBUtil.connect(FyConfig.getUAP_DB_CONFIG());
			log.info("正式Operator:" + fundsBean.getOperator());

			conn.setAutoCommit(false);
			pst = conn.prepareStatement(insertSQL);
			pst.setString(1, fundsBean.getPk_id());
			pst.setString(2, fundsBean.getBill_no());

			/*
			 * if (fundsBean.getPk_corp().equals("1044") ||
			 * fundsBean.getPk_corp().equals("1003") ||
			 * fundsBean.getPk_corp().equals("1016") ||
			 * fundsBean.getPk_corp().equals("1043")) { uappk_corp = "1002"; } else {
			 * uappk_corp = fundsBean.getPk_corp(); } log.info("~~~~~~~pk_corp:" +
			 * uappk_corp + "~~fundsBean.getPk_corp():" + fundsBean.getPk_corp() +
			 * "~~~fundsBean.getPk_costsubj():" + fundsBean.getPk_costsubj());
			 */
			pst.setString(3, uappk_corp);
			if (fundsBean.getPk_costsubj().equals("专利费用")) {
				pst.setString(4, "其他管理销售费用");
				// System.out.println("????????");
			} else {
				pst.setString(4, fundsBean.getPk_costsubj());
				// System.out.println("++++++++"+fundsBean.getPk_costsubj());
			}
			pst.setString(5, fundsBean.getCurr_code());
			pst.setString(6, fundsBean.getBill_date());
			pst.setString(7, fundsBean.getBill_amount());
			pst.setString(8, fundsBean.getAdv_amount());
			pst.setString(9, fundsBean.getOpp_corp());
			pst.setString(10, fundsBean.getOpp_acc_name());
			pst.setString(11, fundsBean.getOpp_acc_no());
			pst.setString(12, fundsBean.getOpp_acc_bank());
			pst.setString(13, fundsBean.getOpp_acc_bank_type());
			// pst.setString(14, MyUtil.getLimitLengthString(Abs, 50,root));
			pst.setString(14, AbsValue);
			pst.setString(15, fundsBean.getMemo());
			pst.setString(16, fundsBean.getVoucher_count());
			pst.setString(17, fundsBean.getOperator());
			pst.setString(18, fundsBean.getOperator_date());
			pst.setString(19, "1");
			pst.setString(20, fundsBean.getBill_no());
			pst.execute();
			conn.commit();
			success = true;

		} catch (Exception e) {
			DBUtil.rollback(conn);
			e.printStackTrace();
			log.error(new StringBuilder().append("资金系统写入数据异常，异常单据号为:").append(fundsBean.getBill_no()).toString(), e);
		} finally {
			DBUtil.setAutoCommit(conn, true);
			DBUtil.close(pst, conn);
		}
		return success;
	}

	public static Connection connect(String driverClassName, String url, String userName, String password)
			throws Exception {
		Class.forName(driverClassName);
		DriverManager.setLoginTimeout(60);
		return DriverManager.getConnection(url, userName, password);
	}

	// 获取下拉值
	public String getUnitCode(String code, String temp) {
		Connection conn2 = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		try {
			conn2 = DBUtil.connect(FyConfig.getOA_DB_CONFIG());
			pst = conn2.prepareStatement(LOOKUP_XIALA_XINGJI);
			pst.setString(1, code);
			pst.setString(2, temp);
			rs = pst.executeQuery();
			if (rs.next()) {
				code = rs.getString(1);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			DBUtil.close(rs, pst);
		}
		return code;
	}

	// 费用明细
	public boolean CostSave(int temp, String Bill_no) {
		boolean success = false;
		Connection conn1 = null;
		PreparedStatement pst = null;
		try {
			if (uappk_corp == "1002") {
				if (fundsBean.getP_dept_list().get(temp).equals("")) {
					P_dept = "缺省";
				} else {
					P_dept = getUnitCode(fundsBean.getP_dept_list().get(temp), "-3492353121871183070");
				}
				if (Bill_no.indexOf("B") != -1) {
					// 报销封面费用类型
					P_type = getUnitCode(fundsBean.getP_type_list().get(temp), "8157573833659796347");
				} else {
					// 差旅费用费用类型
					P_type = getUnitCode(fundsBean.getP_type_list().get(temp), "-6471804149242051035");
				}

			} else {
				if (fundsBean.getP_dept_list().get(temp).equals("")) {
				P_dept = "缺省";
			} else {
				P_dept = fundsBean.getP_dept_list().get(temp);
			}
				if (Bill_no.indexOf("B") != -1) {
					// 测试值
					P_type = getUnitCode(fundsBean.getP_type_list().get(temp), "-2789316785681579454");
				} else {
					// 测试值
					P_type = getUnitCode(fundsBean.getP_type_list().get(temp), "-7162621463629380870");
				}
			}
			// log.info("P_dept:" + P_dept + "P_type:" + P_type);
			//// UAP测试数据库
			/*
			 * conn1 = connect("oracle.jdbc.driver.OracleDriver",
			 * "jdbc:oracle:thin:@10.112.0.32:1521:uap", "uapnc", "uapnc");
			 */
			//// UAP正式数据库
			conn1 = DBUtil.connect(FyConfig.getUAP_DB_CONFIG());
			Date now = new Date();
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// 可以方便地修改日期格式
			String costDate = dateFormat.format(now);
			conn1.setAutoCommit(false);
			pst = conn1.prepareStatement(insertCostSQL);
			// P_ID,P_CORP,P_DEPT,P_TYPE,P_COST

			/*
			 * if (Abs.length() > 50) { AbsValue = Abs.substring(0, 49); } else { AbsValue =
			 * Abs; }
			 */
			pst.setString(1, fundsBean.getBill_no());
			pst.setString(2, uappk_corp);
			/*
			 * if (fundsBean.getP_dept_list().get(temp).equals("")) { P_dept = "缺省"; } else
			 * { P_dept = getUnitCode(fundsBean.getP_dept_list().get(temp),
			 * "-3492353121871183070"); }
			 */

			pst.setString(3, P_dept);

			/*
			 * if (Bill_no.indexOf("B") != -1) { // 报销封面费用类型
			 * 
			 * P_type = getUnitCode(fundsBean.getP_type_list().get(temp),
			 * "8157573833659796347");
			 * 
			 * } else { // 差旅费用费用类型 P_type =
			 * getUnitCode(fundsBean.getP_type_list().get(temp), "-6471804149242051035"); }
			 */
			pst.setString(4, P_type);
			log.info("部门：" + P_dept + "类型：" + P_type + "费用：" + fundsBean.getP_cost_list().get(temp));
			pst.setString(5, fundsBean.getP_cost_list().get(temp));
			pst.setString(6, costDate);
			/*
			 * if (Bill_no.indexOf("B") != -1) { // pst.setString(7, fundsBean.getAbs());
			 * pst.setString(7, AbsValue + root); } else { pst.setString(7, AbsValue +
			 * root); }
			 */
			pst.setString(7, AbsValue);
			pst.execute();
			conn1.commit();
			success = true;
		} catch (Exception e) {
			DBUtil.rollback(conn1);
			e.printStackTrace();
			log.error(new StringBuilder().append("费用明细写入数据异常，异常单据号为:").append(fundsBean.getBill_no()).toString(), e);
		} finally {
			DBUtil.setAutoCommit(conn1, true);
			DBUtil.close(pst, conn1);
		}
		return success;
	}
}
	// 费用明细
/*	public boolean CostSaveCC(int temp, String Bill_no) {
		boolean success = false;
		Connection conn1 = null;
		PreparedStatement pst = null;
		try {
			//// UAP测试数据库
			
			 * conn1 = connect("oracle.jdbc.driver.OracleDriver",
			 * "jdbc:oracle:thin:@10.112.0.32:1521:uap", "uapnc", "uapnc");
			 
			//// UAP正式数据库
			conn1 = DBUtil.connect(FyConfig.getUAP_DB_CONFIG());
			Date now = new Date();
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// 可以方便地修改日期格式
			String costDate = dateFormat.format(now);
			conn1.setAutoCommit(false);
			pst = conn1.prepareStatement(insertCostSQL);
			// P_ID,P_CORP,P_DEPT,P_TYPE,P_COST

			
			 * if (Abs.length() > 50) { AbsValue = Abs.substring(0, 49); } else { AbsValue =
			 * Abs; }
			 
			pst.setString(1, fundsBean.getBill_no());
			pst.setString(2, uappk_corp);
			pst.setString(3, fundsBean.getP_dept_list().get(temp));
			if (Bill_no.indexOf("B") != -1) {
				// 报销封面费用类型
				P_type = getUnitCode(fundsBean.getP_type_list().get(temp), "8157573833659796347");
			} else {
				// 差旅费用费用类型
				P_type = getUnitCode(fundsBean.getP_type_list().get(temp), "-6471804149242051035");
			}
			pst.setString(4, fundsBean.getP_type_list().get(temp));
			log.info("部门：" + fundsBean.getP_dept_list().get(temp) + "类型：" + fundsBean.getP_type_list().get(temp) + "费用："
					+ fundsBean.getP_cost_list().get(temp));
			pst.setString(5, fundsBean.getP_cost_list().get(temp));
			pst.setString(6, costDate);
			
			 * if (Bill_no.indexOf("B") != -1) { // pst.setString(7, fundsBean.getAbs());
			 * pst.setString(7, AbsValue + root); } else { pst.setString(7, AbsValue +
			 * root); }
			 
			pst.setString(7, AbsValue);
			pst.execute();
			conn1.commit();
			success = true;
		} catch (Exception e) {
			DBUtil.rollback(conn1);
			e.printStackTrace();
			log.error(new StringBuilder().append("费用明细写入数据异常，异常单据号为:").append(fundsBean.getBill_no()).toString(), e);
		} finally {
			DBUtil.setAutoCommit(conn1, true);
			DBUtil.close(pst, conn1);
		}
		return success;
	}

}*/

/*
 * package fy.uap.dao;
 * 
 * 
 * import org.apache.commons.logging.Log; import
 * org.apache.commons.logging.LogFactory;
 * 
 * import fy.uap.bean.FundsBean; import fy.util.MyUtil;
 * 
 * import fy.uap.dao.MqReqXml; import fy.uap.dao.RequestNoTimerTask; import
 * com.soa.eis.adapter.framework.message.IMsgObject; import
 * com.soa.eis.adapter.framework.requester.IServiceRequester; import
 * com.soa.eis.adapter.framework.requester.impl.BaseServiceRequester; import
 * com.soa.eis.adapter.framework.utils.log.LogUtil;
 * 
 * 
 * 
 * public class FundsDao {
 * 
 * private static Log log = LogFactory.getLog(FundsDao.class);
 * 
 * private FundsBean fundsBean;
 * 
 * public void setFundsBean(FundsBean fundsBean) { this.fundsBean = fundsBean;
 * 
 * }
 * 
 * 
 * 
 * 
 * 
 * 
 * public boolean save() throws Exception{
 * 
 * boolean success = false;
 * 
 * String p1 = fundsBean.getPk_id(); String p2 = "'"+fundsBean.getBill_no()+"'";
 * String p3 = fundsBean.getPk_corp(); String p4 = "其他管理销售费用"; if(
 * !fundsBean.getPk_costsubj().equals("专利费用")){ p4 ="'"+
 * fundsBean.getPk_costsubj()+"'"; System.out.println("????????"); } String p5 =
 * "'"+fundsBean.getCurr_code()+"'"; String p6 = fundsBean.getBill_date();
 * String p7 = fundsBean.getBill_amount(); String p8 =
 * fundsBean.getAdv_amount(); String p9 = "'"+fundsBean.getOpp_corp()+"'";
 * String p10 ="'"+ fundsBean.getOpp_acc_name()+"'"; String p11 =
 * fundsBean.getOpp_acc_no(); String p12 = fundsBean.getOpp_acc_bank(); String
 * p13 = "'"+fundsBean.getOpp_acc_bank_type()+"'"; String p14 =
 * "'"+MyUtil.getLimitLengthString(fundsBean.getAbs(), 400, "…")+"'"; String p15
 * = fundsBean.getMemo(); String p16 = fundsBean.getVoucher_count(); String p17
 * = fundsBean.getOperator(); String p18 = fundsBean.getOperator_date(); String
 * p19 = "1"; String p20 = "'"+fundsBean.getBill_no()+"'"; //String insertSQL
 * ="insert into FYFUND_OA_BILLCOST_TEMP (PK_ID,BILL_NO,PK_CORP,PK_COSTSUBJ,CURR_CODE,BILL_DATE,BILL_AMOUNT,ADV_AMOUNT,OPP_CORP,OPP_ACC_NAME,OPP_ACC_NO,OPP_ACC_BANK,OPP_ACC_BANK_TYPE,ABS,MEMO,VOUCHER_COUNT,OPERATOR,OPERATOR_DATE,BILL_STATUS) select "
 * +p1+","+p2+","+
 * p3+",(select nvl(pk_costsubj,'') from dual left join (select a.pk_costsubj from v_fyfund_costsubj_for_oa a where a.costname = "
 * +p4+" and rownum = 1) on 1 = 1),"+p5+","+p6+","+p7+","+p8+","+p9+","+p10+","+
 * p11+","+p12+","+p13+","+p14+","+p15+","+p16+","+p17+","+p18+","+
 * p19+" from dual where not exists(select * from FYFUND_OA_BILLCOST_TEMP t where t.bill_no = "
 * +p20+")"; String insertSQL
 * ="insert into FYFUND_OA_BILLCOST_TEMP_ZY(PK_ID,BILL_NO,PK_CORP,PK_COSTSUBJ,CURR_CODE,BILL_DATE,BILL_AMOUNT,ADV_AMOUNT,OPP_CORP,OPP_ACC_NAME,OPP_ACC_NO,OPP_ACC_BANK,OPP_ACC_BANK_TYPE,ABS,MEMO,VOUCHER_COUNT,OPERATOR,OPERATOR_DATE,BILL_STATUS) select "
 * +p1+","+p2+","+
 * p3+",(select nvl(pk_costsubj,'') from dual left join (select a.pk_costsubj from v_fyfund_costsubj_for_oa a where a.costname = "
 * +p4+" and rownum = 1) on 1 = 1),"+p5+","+p6+","+p7+","+p8+","+p9+","+p10+","+
 * p11+","+p12+","+p13+","+p14+","+p15+","+p16+","+p17+","+p18+","+
 * p19+" from dual where not exists(select * from FYFUND_OA_BILLCOST_TEMP_ZY t where t.bill_no = "
 * +p20+")"; // MQ调用接口 IServiceRequester Requester =
 * BaseServiceRequester.getInstance(); IMsgObject req = MqReqXml.add("06004",
 * "06007000000002",String.valueOf(++RequestNoTimerTask.requestNo));
 * req.setReqValue("string", insertSQL); IMsgObject respMo = null; try { //
 * 传入请求报文对象，返回响应报文对象。 respMo = Requester.execute(req);
 * LogUtil.getInstance().info(respMo); LogUtil.getInstance().info(
 * "///////////////////////////////插入返回信息//////////////////////////////////");
 * LogUtil.getInstance().info(respMo.getServResStatus() + "------" +
 * respMo.getResValue("return"));
 * if("COMPLETE".equals(respMo.getServResStatus())&&respMo.getResValue("return")
 * .equals("true")){ success = true; }else{ log.error( new
 * StringBuilder().append("资金系统写入数据异常，异常单据号为:")
 * .append(fundsBean.getBill_no()).toString()); } } catch (Exception e) {
 * e.printStackTrace(); } return success; } }
 */
/*
 * package fy.uap.dao;
 * 
 * import java.sql.Connection; import java.sql.PreparedStatement; import
 * java.sql.ResultSet; import java.util.Date; import java.text.SimpleDateFormat;
 * 
 * import org.apache.commons.logging.Log; import
 * org.apache.commons.logging.LogFactory;
 * 
 * import fy.config.FyConfig; import fy.uap.bean.FundsBean; import
 * fy.util.DBUtil; import fy.util.MyUtil;
 * 
 * 
 * public class FundsDao {
 * 
 * private static Log log = LogFactory.getLog(FundsDao.class);
 * 
 * private FundsBean fundsBean;
 * 
 * 
 * private static final String insertSQL =
 * "insert into FYFUND_OA_BILLCOST_TEMP (PK_ID,BILL_NO,PK_CORP,PK_COSTSUBJ,CURR_CODE,BILL_DATE,BILL_AMOUNT,ADV_AMOUNT,OPP_CORP,OPP_ACC_NAME,OPP_ACC_NO,OPP_ACC_BANK,OPP_ACC_BANK_TYPE,ABS,MEMO,VOUCHER_COUNT,OPERATOR,OPERATOR_DATE,BILL_STATUS) select ?,?,?,(select nvl(pk_costsubj,'') from dual left join (select a.pk_costsubj from v_fyfund_costsubj_for_oa a where a.costname = ? and rownum = 1) on 1 = 1),?,?,?,?,?,?,?,?,?,?,?,?,?,?,? from dual where not exists(select * from FYFUND_OA_BILLCOST_TEMP t where t.bill_no = ?)"
 * ; private static final String insertCostSQL
 * ="insert into OA_Cost_To_UAP (P_ID,P_CORP,P_DEPT,P_TYPE,P_COST,TS)values ( ?, ?, ?, ?, ?, ?)"
 * ;
 * 
 * // 查下拉值 注意REF_ENUMID正式和测试不同 private final static String LOOKUP_XIALA_XINGJI =
 * "SELECT c.SHOWVALUE FROM  CTP_ENUM_ITEM  c WHERE c.ENUMVALUE=? AND c.REF_ENUMID=?"
 * ; public void setFundsBean(FundsBean fundsBean) { this.fundsBean = fundsBean;
 * 
 * }
 * 
 * public boolean save() {
 * 
 * Connection conn = null; PreparedStatement pst = null;
 * 
 * boolean success = false;
 * 
 * try { conn = DBUtil.connect(FyConfig.getUAP_DB_CONFIG());
 * 
 * conn.setAutoCommit(false); pst = conn.prepareStatement(insertSQL);
 * 
 * pst.setString(1, fundsBean.getPk_id()); pst.setString(2,
 * fundsBean.getBill_no()); pst.setString(3, fundsBean.getPk_corp());
 * pst.setString(4, fundsBean.getPk_costsubj()); pst.setString(5,
 * fundsBean.getCurr_code()); pst.setString(6, fundsBean.getBill_date());
 * pst.setString(7, fundsBean.getBill_amount()); pst.setString(8,
 * fundsBean.getAdv_amount()); pst.setString(9, fundsBean.getOpp_corp());
 * pst.setString(10, fundsBean.getOpp_acc_name()); pst.setString(11,
 * fundsBean.getOpp_acc_no()); pst.setString(12, fundsBean.getOpp_acc_bank());
 * pst.setString(13, fundsBean.getOpp_acc_bank_type()); pst.setString(14,
 * MyUtil.getLimitLengthString(fundsBean.getAbs(), 400, "…")); pst.setString(15,
 * fundsBean.getMemo()); pst.setString(16, fundsBean.getVoucher_count());
 * pst.setString(17, fundsBean.getOperator()); pst.setString(18,
 * fundsBean.getOperator_date()); pst.setString(19, "1"); pst.setString(20,
 * fundsBean.getBill_no());
 * 
 * pst.execute();
 * 
 * conn.commit(); log.info("11111111111"+fundsBean.getBill_no());
 * CostSave(conn); if(
 * fundsBean.getBill_no().indexOf("C")!=-1||fundsBean.getBill_no().indexOf(
 * "BFIN")!=-1){
 * 
 * } success = true;
 * 
 * 
 * } catch (Exception e) { DBUtil.rollback(conn); e.printStackTrace();
 * log.error( new StringBuilder().append("资金系统写入数据异常，异常单据号为:")
 * .append(fundsBean.getBill_no()).toString(), e); } finally {
 * DBUtil.setAutoCommit(conn, true); DBUtil.close(pst, conn); } return success;
 * }
 * 
 * 
 * //费用明细 public boolean CostSave(Connection conn) {
 * System.out.println("`````````````````"); boolean success = false; //
 * Connection conn = null; PreparedStatement pst = null; try { conn =
 * DBUtil.connect(FyConfig.getUAP_DB_CONFIG()); Date now = new Date();
 * SimpleDateFormat dateFormat = new
 * SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//可以方便地修改日期格式 String costDate =
 * dateFormat.format( now ); System.out.println(costDate);
 * 
 * conn.setAutoCommit(false); pst = conn.prepareStatement(insertCostSQL);
 * 
 * //P_ID,P_CORP,P_DEPT,P_TYPE,P_COST pst.setString(1, fundsBean.getBill_no());
 * pst.setString(2, fundsBean.getPk_corp()); pst.setString(3,
 * getUnitCode(fundsBean.getP_dept(),"-2712117938696927012")); pst.setString(4,
 * getUnitCode( fundsBean.getP_type(),"-8035820474004256980")); pst.setString(5,
 * fundsBean.getP_cost()); pst.setString(6,costDate);
 * 
 * pst.execute();
 * 
 * conn.commit(); success = true;
 * 
 * } catch (Exception e) { DBUtil.rollback(conn); e.printStackTrace();
 * log.error( new StringBuilder().append("费用明细写入数据异常，异常单据号为:")
 * .append(fundsBean.getBill_no()).toString(), e); } finally {
 * DBUtil.setAutoCommit(conn, true); DBUtil.close(pst, conn); } return success;
 * }
 * 
 * // 获取下拉值 public String getUnitCode(String code, String temp) { Connection
 * conn = null; PreparedStatement pst = null; ResultSet rs = null;
 * 
 * try { conn = DBUtil.connect(FyConfig.getOA_DB_CONFIG()); pst =
 * conn.prepareStatement(LOOKUP_XIALA_XINGJI); pst.setString(1, code);
 * pst.setString(2, temp); rs = pst.executeQuery(); if (rs.next()) { code =
 * rs.getString(1); } } catch (Exception e) { e.printStackTrace(); } finally {
 * DBUtil.close(rs, pst); } return code; }
 * 
 * 
 * }
 * 
 * 
 * 
 */